<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        #canvas {
            display: block;
            margin: 200px auto;
            border: 1px solid #000;
            box-shadow: 1px 1px #ccc;
        }
    </style>
</head>

<body>
    <canvas id="canvas" height="600" width="600"></canvas>

    <script>
        const canvas = document.getElementById("canvas");
        const ctx = canvas.getContext("2d");

        ctx.globalCompositeOperation = "destination-over";
        ctx.beginPath();
        ctx.strokeStyle = "red"; // 设置绘图的描边颜色或样式 // strokeStyle = color： 给图形描边填色。 需要再stroke函数前调用
        ctx.lineWidth = 5;
        ctx.arc(300, 300, 125, 0, Math.PI * 2, true);
        ctx.stroke();
        ctx.closePath();

        // ctx.globalCompositeOperation = "destination-out";
        // ctx.beginPath();
        // ctx.strokeStyle = "blue";
        // ctx.rect(220, 220, 160, 160);
        // ctx.stroke();
        // ctx.closePath();
 ctx.globalCompositeOperation = "destination-over";
        ctx.beginPath();
        ctx.strokeStyle = "violet"; // 设置绘图的描边颜色或样式
        ctx.lineWidth = 50;
        ctx.arc(300, 300, 125, 0, Math.PI * 2, true);
        ctx.stroke();
        ctx.closePath();

 ctx.globalCompositeOperation = "destination-over";

        ctx.beginPath()
        ctx.lineWidth = 50
        ctx.strokeStyle = 'blue'
        ctx.rect(225, 225, 150, 150)
        ctx.stroke()
        ctx.closePath();

        //ctx.globalCompositeOperation = "destination-over"
        //ctx.beginPath()
        //ctx.fillStyle = 'pink' //fillStyle = color：给图形填充颜色。需要再fill函数前调用
        //ctx.fillRect(150, 150, 300, 300)
        //ctx.closePath()
    </script>
</body>

</html>